import api from "@/api/apiConfig";
import ajax from "@/api/http";
import store from "@/store";
import router from "@/router";

export default {
  goPage(routerName, params, query) {
    router.push({
      name: routerName,
      params: { id: params },
      query: { info: query }
    });
  },
  getInfo(cb) {
    if (localStorage.getItem("mtoken")) {
      ajax
        .post(api.personalCenter)
        .then(() => {
          store.dispatch("changeLogin", true);
          cb && cb();
        })
        .catch(() => {
          cb && cb();
        });
    } else {
      cb && cb();
    }
  }
};
